package com.example.leave.common;

import com.example.leave.form.StartEndDateTimeForm;
import com.example.leave.pojo.DateTime;
import com.example.leave.pojo.StartEndTimestamp;

import java.sql.Timestamp;

public class DateTimeUtil {
    public static StartEndTimestamp startEndDateTimeVoToStartEndTimestamp(StartEndDateTimeForm startEndDateTimeForm) {
        StartEndTimestamp startEndTimestamp = new StartEndTimestamp();
        startEndTimestamp.setStartTime(Timestamp.valueOf(
                startEndDateTimeForm.getStartDate().toString() + " " + startEndDateTimeForm.getStartTime().toString()));
        startEndTimestamp.setEndTime(Timestamp.valueOf(
                startEndDateTimeForm.getEndDate().toString() + " " + startEndDateTimeForm.getEndTime().toString()));
        return startEndTimestamp;

    }

    public static Timestamp dateTimeToTimestamp(DateTime dateTime) {
        return Timestamp.valueOf(
                dateTime.getDate().toString() + " " + dateTime.getTime().toString());
    }
}
